home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Demo's / Igor Demo Pro / 1 PutContentsIn Igor Pro Folder / WaveMetrics Procedures / Graphing / Graph Utility Procs < prev    next >
Text File  |  1996-01-30  |  3KB  |  94 lines

  1. // Graph Utility Procs, Version 1.2, JP960124
  2.  
  3. // Version 1.1 created to be liberal name aware. Also added option to  CopyTraceSettings.
  4. // Version 1.2, added ApplyStyleMacro.
  5.  
  6. #include <Strings as Lists>
  7. #include <String Substitution>
  8.  
  9. #pragma rtGlobals=1        // This mainly acts as notice that this proc is Igor 3.0 savvy
  10.  
  11. // This routine reads the settings of the srcaxis of the top graph and copies them
  12. // to the destaxis
  13. Function CopyAxisSettings(srcaxis,destaxis)
  14.     String srcaxis,destaxis
  15.  
  16.     String info=  AxisInfo("",srcaxis)
  17.     Variable sstop= strsearch(info, "RECREATION:", 0)
  18.     info= info[sstop+strlen("RECREATION:"),1e6]        // want just recreation stuff
  19.     Variable i=0
  20.     String dstr= "("+destaxis+")"    // i.e., (left)
  21.     String sitem,xstr
  22.     do
  23.         sitem= GetStrFromList(info,i,";")
  24.         if( strlen(sitem) == 0 )
  25.             break;
  26.         endif
  27.         xstr= "ModifyGraph "+StrSubstitute("(x)",sitem,dstr)
  28.         Execute xstr
  29.         i+=1
  30.     while(1)
  31. End
  32.  
  33.  
  34. // This routine reads the settings of the given trace on the top graph and copies them
  35. // to the destination trace
  36. // Modifyed 951107,LH: Can now accept either a wave name and instance or a
  37. // trace name. To use the later, specify -1 for the instance.
  38. //
  39. Function CopyTraceSettings(srcwave,srcinstance,destwave,destinstance)
  40.     String srcwave,destwave
  41.     Variable srcinstance,destinstance
  42.     
  43.     if( srcinstance == -1 )
  44.         srcinstance= 0            // only used by TraceInfo which knows how to handle trace name
  45.     endif
  46.  
  47.     String info=  TraceInfo("",srcwave,srcinstance)
  48.     Variable sstop= strsearch(info, "RECREATION:", 0)
  49.     info= info[sstop+strlen("RECREATION:"),1e6]        // want just recreation stuff
  50.     Variable i=0
  51.     String dstr
  52.     if( destinstance == -1 )
  53.         dstr= "("+destwave+")"            // i.e., (jack#1)
  54.     else
  55.         dstr= "("+PossiblyQuoteName(destwave)+"#"+num2istr(destinstance)+")"
  56.     endif
  57.     String sitem,xstr
  58.     do
  59.         sitem= GetStrFromList(info,i,";")
  60.         if( strlen(sitem) == 0 )
  61.             break;
  62.         endif
  63.         xstr= "ModifyGraph "+StrSubstitute("(x)",sitem,dstr)
  64.         Execute xstr
  65.         i+=1
  66.     while(1)
  67. End
  68.  
  69. // This routine applies the style macro contained in styleMacroStr to the top window
  70. // The usual method of acquiring the style macro is
  71. // String styleMacroStr= WinRecreation("",1)    | "" means top window
  72. Function ApplyStyleMacro(styleMacroStr)
  73.     String styleMacroStr
  74.  
  75.     String startSrch= "modifying window...\r"
  76.     Variable sstart= strsearch(styleMacroStr,startSrch, 0)
  77.     Variable ssend= strsearch(styleMacroStr, "EndMacro", 0)
  78.     if( (sstart < 0) %| (ssend <= sstart) )
  79.         return 1    // failure
  80.     endif
  81.     
  82.     Variable line=2    // skip line 0 and line 1
  83.     String cmd
  84.     do
  85.         cmd= GetStrFromList(styleMacroStr,line,"\r")
  86.         if( CmpStr(cmd,"EndMacro") == 0 )
  87.             break;
  88.         endif
  89.         Execute cmd
  90.         line+=1
  91.     while(1)
  92.     return 0    // success
  93. End
  94.